package com.wsg.dep.util.office;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: TableInfo
 * @author: 承泽
 * @date: 2025/3/25 11:00
 * @description:
 */
public class TableInfo {
    private int rowNumb;
    private int colNumb;

    private List<String> head = new ArrayList<>();
    private List<List<String>> body = new ArrayList<>();

    public TableInfo(int rows, int cols) {
        this.rowNumb = rows;
        this.colNumb = cols;
    }

    public int getRowNumb() {
        return rowNumb;
    }

    public int getColNumb() {
        return colNumb;
    }

    public List<String> getHead() {
        return head;
    }

    public List<List<String>> getBody() {
        return body;
    }

    /**
     * 设置表头
     * @param cols
     */
    public void setHead(String... cols) {
        if (null != cols && cols.length >= colNumb) {
            head.clear();
            for (int i = 0; i < colNumb; i++) {
                head.add(cols[i]);
            }
        }
    }

    public void addRow(String... rows) {
        if (null != rows && rows.length >= colNumb && body.size() < rowNumb) {
            List<String> row = new ArrayList<>();
            for (int i = 0; i < colNumb; i++) {
                row.add(rows[i]);
            }
            body.add(row);
        }
    }

}
